<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>小猪出生</title>
    <link href="../../css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="../../font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="../../css/animate.css" rel="stylesheet">
    <link href="../../css/style.css?v=2.2.0" rel="stylesheet">

</head>
<body class="top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom white-bg">
            <nav class="navbar navbar-static-top" role="navigation">
                <div class="navbar-header">
                    <button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">
                        <i class="fa fa-reorder"></i>
                    </button>
                    <a href="Farm_navigation.html#" class="navbar-brand">PIE</a>
                </div>
                <div class="navbar-collapse collapse" id="navbar">
                    <ul class="nav navbar-nav">
                        <li class="active">
                            <a aria-expanded="false" role="button" href="Farm_navigation.html"> 返回主页</a>
                        </li>
                    </ul>
                    <ul class="nav navbar-top-links navbar-right">
                        <li id="logout">
                            <a >
                                <i class="fa fa-sign-out"></i> 退出
                            </a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>


        <div class="middle-box text-center loginscreen   animated fadeInDown">
            <div>
                <form id="form">
                    <div>

                        <h3 class="">小猪出生</h3>

                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入13位小猪标号" required="" id="id" name="pigId">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入6位养殖场ID" required="" id="Fid" name="fid">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入18位饲养员ID" required="" id="Bid" name="bid">
                    </div>
                    <div class="form-group" >
                        <input class="laydate-icon form-control layer-date" placeholder="请输入出生日期" id="hello" name="Hello">
                    </div>
                    <div class="form-group draggable">
                        <div class="">
                            <select class="form-control" id="breed" name="Breed">b
                                <option>品种1</option>
                                <option>品种2</option>
                                <option>品种3</option>
                                <option>品种4</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group draggable">
                        <div class="">
                            <select class="form-control" id="gender" name="Gender">
                                <option value="1">雌</option>
                                <option value="0">雄</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="请输入出生体重（如：12.23）" required="" id="weight" name="Weight">
                    </div>
                    <button id="btnpb" type="button" class="btn btn-primary block full-width m-b">提交</button>
                </form>
            </div>
        </div>



        <div class="footer">
            <div class="pull-right">
                By：<a href="http://www.zi-han.net" target="_blank">zihan's blog</a>
            </div>
            <div>
                <strong>Copyright</strong> H+ &copy; 2014
            </div>
        </div>

    </div>
</div>
<!-- Mainly scripts -->
<script src="../../js/jquery-3.3.1.js"></script>
<script src="../../js/bootstrap.min.js?v=3.4.0"></script>

<!-- layerDate plugin javascript -->
<!-- layerDate plugin javascript -->
<script src="../../js/plugins/layer/laydate/laydate.js"></script>
<script>
    //外部js调用
    laydate({
        elem: '#hello', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
        event: 'focus' //响应事件。如果没有传入event，则按照默认的click
    });

    //日期范围限制
    var start = {
        elem: '#start',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(), //设定最小日期为当前日期
        max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        elem: '#end',
        format: 'YYYY/MM/DD hh:mm:ss',
        min: laydate.now(),
        max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
</script>

<script>
    $(function(){
        $(document).ready(function(){
            $("#btnpb").click(function(){
                var pig = {
                    id: $("#id").val(),
                    farmId: $("#Fid").val(),
                    breederId: $("#Bid").val(),
                    date: $("#hello").val(),
                    breed: $("#breed").val(),
                    gender: $("#gender").val(),
                    weight:$("#weight").val()
                }
                var Pig=JSON.stringify(pig);
                //alert(Pig)
                $.post({
                    url: "http://localhost:8080/farmreception",
                    headers: {
                        "Content-Type": "application/json; charset=utf-8"
                    }
                }, Pig,function (data){
                    if(data=="请先登录")
                    {
                        alert(data);
                        location.assign("http://localhost:8080/login/Login.html");
                    }
                    else {
                        alert(data);
                        location.reload();
                    }
                })
            });
        });
    });

</script>

<script src="../../js/plugins/validate/jquery.validate.min.js"></script>
<script src="../../js/plugins/validate/messages_zh.min.js"></script>

<script>
    $(document).ready(function () {
        $("#form").validate({
            rules:{
                pigId:{
                    required:true,
                    number:true,
                    maxlength:13
                },
                fid:{
                    required:true,
                    number:true,
                    maxlength:6
                },
                bid:{
                    required:true,
                    number:true,
                    maxlength:18
                },
                Hello:{
                    required:true,
                    maxlength:10
                },
                Weight:{
                    required:true,
                    number:true,
                    maxlength:5
                }
            }
        })
    })
</script>
<script>
    $("#logout").click(function(){
        $.get("http://localhost:8080/logout",function () {
            location.assign("http://localhost:8080/PorkTraceability/login/Login.html");
        })
    })
</script>
</body>
</html>








